# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=fingerprinter
pkgver=486.e0078b4
pkgrel=1
groups=('blackarch' 'blackarch-webapp' 'blackarch-fingerprint')
pkgdesc='CMS/LMS/Library etc Versions Fingerprinter.'
arch=('any')
url='https://github.com/erwanlr/Fingerprinter'
license=('CC-BY-NC-4.0')
depends=('ruby' 'ruby-pkg-config' 'libxslt' 'ruby-bundler')
makedepends=('git' 'ruby-bundler')
source=("$pkgname::git+https://github.com/erwanlr/Fingerprinter.git")
sha512sums=('SKIP')
install="$pkgname.install"

pkgver() {
  cd $pkgname

  ( set -o pipefail
    git describe --long --tags --abbrev=7 2>/dev/null |
      sed 's/\([^-]*-g\)/r\1/;s/-/./g' ||
    printf "%s.%s" "$(git rev-list --count HEAD)" \
      "$(git rev-parse --short=7 HEAD)"
  )
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname" README.md

  rm README.md

  cp -a --no-preserve=ownership * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec bundle exec "$pkgname.rb" "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

